local Tickable = {}
Tickable.__index = Tickable
Tickable.ClassName = "Tickable"

--[[
onUpdate	
	Will be called every frame
onLeaveQueue 
	Will be called when Tickable leave queue. 
	(eg. you can free the pooled object here.)
]]
function Tickable.new(onUpdate, onLeaveQueue)
	local self = setmetatable({}, Tickable);
	
	self.isInQueue = false;
	self.isStopped = false;
	
	if onUpdate then
		self.Update = onUpdate;
	else
		self.Update = function(self)
		end
	end
	
	--- C#版的Tickable没有onLeaveQueue。因为C#版里实现了引用计数
	--- TickedQueue里被ticked的是Tickable的WeakRef，当引用计数为0
	--- 时，TickedQueue里对应WeakRef引用对象自动变为null。
	if onLeaveQueue then
		self.OnLeaveQueue = onLeaveQueue;
	else
		self.OnLeaveQueue = function(self)
		end
	end	
	return self;
end

return Tickable;
